#include <iostream>
#include <vector>
using namespace std;

//快速排序（从小到大）
void quickSort(int left, int right, vector<int>& arr)
{
	if(left >= right)
		return;
	int i, j, base, temp;
	i = left, j = right;
	base = arr[left];  //取最左边的数为基准数
	while (i < j)
	{
		while (arr[j] >= base && i < j)
			j--;
		while (arr[i] <= base && i < j)
			i++;
		if(i < j)
		{
			temp = arr[i];
			arr[i] = arr[j];
			arr[j] = temp;
		}
	}
	//基准数归位
	arr[left] = arr[i];
	arr[i] = base;
	quickSort(left, i - 1, arr);//递归左边
	quickSort(i + 1, right, arr);//递归右边
}


int main()
{
	vector<int> arr;
	int num[5] = {3, 2, 4, 1, 5};    //int型数组用于存储输入变量
	int i=0,N=4;

	//while (cin>>num[i]){
	//	N++;
	//}
	for(int i=0;i<=N;i++)
		arr.push_back(num[i]);
	
	printf ("hello,world");

    quickSort(0, N, arr);

	for (int j=0;j<=N;j++)
    	cout << arr[j] << " ";

	system("pause");
    return 0;
}